<?php
/**
 * @author: zhouzhongyuan <435690026@qq.com>
 * @copyright 万虎网络
 * @link http://www.wanhunet.com
 */

namespace common\Utils;


class ViewUtils
{
    public static function addAssetBundle(\yii\base\View $view, $assetBundle)
    {
        self::addEventBeginBody($view, function ($data) use ($assetBundle) {
            /** @var $view \yii\web\View */
            $view = $data->sender;
            $view->registerAssetBundle($assetBundle);
        });
    }

    public static function addEventBeginBody(\yii\base\View $view, $handler)
    {
        $view->on($view::EVENT_BEGIN_PAGE, $handler);
    }
}